home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / miscpas.zip / OHM1.PAS < prev    next >
Pascal/Delphi Source File  |  1984-07-01  |  33KB  |  786 lines

  1.  
  2.  
  3. Program FirstOhm;
  4.  
  5. Var
  6.   Xlow,Yhi,Vlen, Hlen,I,Neq : Integer;   (* Vert.& horiz. line lengths. *)
  7.      Xsc,Ysc,Ty,Y1off,Y2off : Integer;   (* For 80x25 scale. *)
  8. Vindx,Xinc,Yinc,Xwide,Yzero : Integer;
  9.       Xhlow,Xhhi,Yhlow,Yhhi : Integer;   (* Hires coordinates. *)
  10.        V,OH,A,W,Ycept,Slope : Real;      (* Y intercept & slope. *)
  11.   Boom,Ch,Hl,Vl,Ur,Ul,Ll,Lr : Char;
  12.                    Ccontrol : File;
  13. {========================================================================}
  14.                          Procedure MainControl; Forward;
  15. Procedure Node;  Begin
  16. Gotoxy(12,25);Write('Press `N` for next topic, `M` for Menu, `Q` to Quit.');
  17.   Repeat
  18.     Read(Kbd,Ch);
  19.     Ch:=UpCase(Ch);
  20.   until (Ch in ['M','N','Q']);
  21. Gotoxy(12,25);Write('                                                     ');
  22.   If Ch='M' then MainControl;
  23.   If Ch='Q' then Halt;
  24. end;  (* Procedure Node. *)
  25. {========================================================================}
  26. Procedure Boxes;
  27. Begin
  28.  
  29.  Hl:=Char(196); Vl:=Char(179);
  30.  Ur:=Char(191); Ul:=Char(218); Ll:=Char(192); Lr:=Char(217);
  31.  
  32. Gotoxy(Xlow, Yhi);   Write(Ul);     (* Position upper left corner. *)
  33.   For I:=1 to Hlen do begin         (* Write top line and corners. *)
  34.      Write(Hl);
  35.   end;
  36.     Write(Ur);
  37.  
  38.     Xlow:=Xlow+Hlen+1;              (*   X is same for vertical.    *)
  39.   For I:=1 to Vlen do begin         (*  Write R vertical and corner.*)
  40.     Yhi:=Yhi+1;
  41.       Gotoxy(Xlow, Yhi);
  42.         Write(Vl);
  43.   end;
  44. Gotoxy(Xlow, Yhi+1);  Write(Lr);
  45.  
  46.     Yhi:=Yhi+1;
  47.   For I:=1 to Hlen do begin         (*  Y same for horizontal.*)
  48.     Xlow:=Xlow-1;
  49.       Gotoxy(Xlow, Yhi);
  50.         Write(Hl);
  51.   end;
  52. Gotoxy(Xlow-1, Yhi);  Write(Ll);
  53.  
  54.     Xlow:=Xlow-1;                   (*  X same for vertical. *)
  55.   For I:=1 to Vlen do begin
  56.     Yhi:=Yhi-1;
  57.       Gotoxy(Xlow, Yhi);
  58.         Write(Vl);
  59.   end;
  60. end;   (* Procedure Boxes. *)
  61. {---------------------------------------------------------------------}
  62.                    Procedure Key; Forward;
  63. Procedure Border;      (* Puts moving border around screen. *)
  64. Var            Lvert,Rvert,Bl,Bar,Ch : Char;
  65.                              K,Pos,I : Integer;
  66.              Ylow,Yhi,Xlow,Xhi,Hl,Vl : Integer;
  67.   {-----------------------------------------------------------------}
  68. Begin
  69.  
  70.                Xlow:=11;  Hl:=26;   Xhi:=Xlow+2*Hl;
  71.                 Yhi:=1;  Vl:= 3;  Ylow:=Yhi +2*Vl;
  72.  
  73.                   Bl:=Char(32);     Bar:=Char(196);
  74.                Lvert:=Char(124);  Rvert:=Char(124);
  75.   {---------------------------------------------------------------}
  76.   Gotoxy(Xlow,Yhi);
  77. For I:=1 to Hl do begin         (* Horizontal-High *)
  78.   Write(Bar);  Write(Bl);
  79. end;
  80.   Gotoxy(Xlow,Yhi);
  81. For I:=1 to Hl do begin
  82.   Write(Bl); Write(Bar);
  83. end;
  84.   {---------------------------------------------------------------}
  85. For I:=1 to Vl do begin
  86.   K:=I*2;
  87.     Gotoxy(Xlow,Yhi+K-1);  Write(Lvert);
  88.     Gotoxy(Xlow,Yhi+K);    Write(Bl);
  89. end;
  90. For I:=1 to Vl do begin
  91.   K:=I*2;
  92.     Gotoxy(Xlow,Yhi+K-1);  Write(Bl);
  93.     Gotoxy(Xlow,Yhi+K);    Write(Lvert);
  94. end;
  95.   {---------------------------------------------------------------}
  96.   Gotoxy(Xlow,Ylow);
  97. For I:=1 to Hl do begin          (* Horizontal-Low *)
  98.   Write(Bar);  Write(Bl);
  99. end;
  100.   Gotoxy(Xlow,Ylow);
  101. For I:=1 to Hl do begin
  102.   Write(Bl);  Write(Bar);
  103. end;
  104.   {---------------------------------------------------------------}
  105.                                  (* Right Vertical *)
  106. For I:=1 to Vl do begin
  107.   K:=I*2;
  108.     Gotoxy(Xhi,Yhi+K-1);  Write(Lvert);
  109.     Gotoxy(Xhi,Yhi+K);    Write(Bl);
  110. end;
  111.  
  112. For I:=1 to Vl do begin
  113.   K:=I*2;
  114.     Gotoxy(Xhi,Yhi+K-1);  Write(Bl);
  115.     Gotoxy(Xhi,Yhi+K);    Write(lvert);
  116.   end;
  117.  
  118. end;  (* Procedure Border. *)
  119. {---------------------------------------------------------------------}
  120. Procedure Key;
  121.   begin   Gotoxy(26,25); Write('Press any key - ');
  122.     Repeat until keypressed;
  123.           Gotoxy(22,25); Write('                                    ');
  124.   end;
  125. {----------------------------------------------------------------------}
  126.                           Procedure Page3; Forward;
  127. Procedure Page2;
  128.  
  129. Begin    ClrScr;
  130. Gotoxy(1,6);
  131. Writeln('                      BASIC FACTS OF ELECTRONICS.               ');
  132.  
  133. Gotoxy(1,9);
  134. Writeln('                      Electron Flow Measurements    ');
  135. Writeln('                      ~~~~~~~~ ~~~~ ~~~~~~~~~~~~    ');
  136. Writeln('            Pressure   = Volts.      One Volt through          ');
  137. Writeln('            Resistance = Ohms.       One Ohm of resistance is  ');
  138. Writeln('            Flow Rate  = Amps.       One Amp of current.       ');
  139. Writeln;
  140. Writeln('                       A = V/R   or   V = AR.     ');
  141.  
  142.   Xlow:=11; Yhi:=8; Hlen:=51; Vlen:=7;   Boxes;   (* Around measurements. *)
  143. Gotoxy(1,18);
  144. Writeln('     Electricity is electron flow in closed circuits or loops. It occurs');
  145. Writeln('     naturally.  We just make use of it.  To construct and study circui-');
  146. Writeln('     ts, measurements are necessary.  We measure flow rate, and what af-');
  147. Writeln('     fects it.  Everyone uses the same 3 measurements.  And, if we know ');
  148. Writeln('           any 2 of them, we compute the third from the other two.      ');
  149. Writeln('           -------------------------------------------------------  ');
  150.  Key;
  151.  
  152. Gotoxy(10,6);Write('                                            ');
  153.   Xlow:=20; Yhi:= 2; Hlen:=13; Vlen:=3;   Boxes;    (*  Picture boxes. *)
  154.   Xlow:=15; Yhi:= 3; Hlen:= 9; Vlen:=1;   Boxes;
  155. Gotoxy(17,4);  Write('Battery');
  156.   Xlow:=31; Yhi:= 3; Hlen:= 6; Vlen:=1;   Boxes;
  157. Gotoxy(33,4); Write('Bulb');
  158.  
  159.   Gotoxy(48,5);                          (*  Writing schematic. *)
  160.     For I:= 1 to 11 do Write(#196);
  161.   Gotoxy(46,5); Write('V+');
  162.   Gotoxy(59,5); Write('-');
  163.   Gotoxy(52,5); Write('R1');
  164.   Gotoxy(48,3); Write('Schematic');
  165.   Gotoxy(48,4); Write('~~~~~~~~~');
  166.  
  167. For I:= 1 to 10 do  Border;            (* ** Call Moving Border. ** *)
  168.   Key;Clrscr;
  169.  
  170.   Gotoxy(1,6);
  171. Writeln('                           Basic Computing.                         ');
  172. Writeln('                           ~~~~~~~~~~~~~~~~                         ');
  173.   Writeln;
  174. Writeln('        Ohm`s law, V = AR, describes electron flow.  If we know any ');
  175. Writeln('            2 of its terms, no. 3 is computed from the 2 known.     ');
  176.   Writeln;
  177. Writeln('          We define watts from Ohm`s law to provide measurements    ');
  178. Writeln('              of `power.`  Power is another word for energy.        ');
  179.   Writeln;
  180. Writeln('             By definition: W = VA  and  V = AR  so  W = AAR.       ');
  181.   Writeln;
  182. Writeln('               Watts is thus the square of Amps times Ohms.         ');
  183. Writeln('               --------------------------------------------         ');
  184.   Writeln;
  185. Writeln('                          Computing is next.                        ');
  186.  
  187. Node;
  188.   Page3;
  189. end;
  190. {-------------------------------------------------------------------}
  191. Procedure ShortCircuit;
  192.                           Var I : Integer;
  193. Begin    ClrScr;
  194.   TextMode(0);
  195.     For I:= 1 to 5 do begin
  196.       Gotoxy(12,12);
  197.         Write('Short Circuit!');
  198.       Delay(100);
  199.         ClrScr;
  200.       Delay(100);
  201.     end;
  202.   Textmode(2);
  203. end;
  204. {------------------------------------------------------------------}
  205. Procedure WriteStuff;           (* Writes to Screen. *)
  206. begin
  207.   Gotoxy(16,14); If V<100 then
  208.                     Write('Volts are: ',V:5:2) else
  209.                     Write('Volts are: ',V:5:0);
  210.   Gotoxy(37,14);  Write('Ohms are : ',OH:6:0);
  211.  
  212.   Gotoxy(16,15); If A<10 then
  213.                     Write('Amps are : ',A:5:3) else
  214.                  if (10<A) and (A<100) then
  215.                     Write('Amps are : ',A:5:1) else
  216.                     Write('Amps are : ',A:5:0);
  217.   Gotoxy(37,15);  If W<100 then
  218.                   Write('Watts are: ',W:6:2) else
  219.                   Write('Watts are: ',W:6:0);
  220. end;
  221. {-------------------------------------------------------------------}
  222. Procedure Presskey;
  223.   begin   Gotoxy(12,25);
  224.     Write('Press `A` for another `M` for Menu `Q` to quit. ');
  225.       Repeat
  226.         Read(Kbd,Ch);
  227.         Ch:=Upcase(Ch);
  228.       until (Ch in ['A','M','Q']);
  229. Gotoxy(12,25);Write('                                                ');
  230.  
  231. If Ch='A' then gotoxy(1,25); For I:=1 to 10 do Writeln;
  232. If Ch='A' then Gotoxy(10,10);
  233.            Write('                                                    ');
  234.     If Ch='A' then Page3;
  235.     If Ch='M' then MainControl;
  236.     If Ch='Q' then Halt;
  237. end;
  238. {-----------------------------------------------------------------}
  239. Procedure VR;   Label 99;  begin              (* Volts & Ohms *)
  240.   For I:=1 to 6 do begin
  241.     Gotoxy(15,11+I);  Write('                                           ');
  242.   end;
  243.  
  244.   Gotoxy(18,20); Write('Enter Volts ');  Read(V);
  245.   Gotoxy(38,20); Write('Enter Ohms  ');  Read(OH);
  246.      If Oh=0 then ShortCircuit;
  247.      If OH=0 then Goto 99;
  248.  
  249.                                  A:=V/OH;  W:=V*A;
  250.   WriteStuff;
  251. 99:  Presskey;
  252. end;
  253. {-------------------------------------------------------------------}
  254. Procedure VA;  Label 99;  begin               (* Volts & Amps *)
  255.  
  256.   For I:=1 to 6 do begin
  257.     Gotoxy(15,11+I);  Write('                                           ');
  258.   end;
  259.  
  260.   Gotoxy(18,20); Write('Enter Volts ');  Read(V);
  261.   Gotoxy(38,20); Write('Enter Amps  ');  Read(A);
  262.     If A=0 then Goto 99;
  263.                                 OH:=V/A;  W:=V*A;
  264.   Writestuff;
  265. 99:  Presskey;
  266.  
  267. end;
  268. {-------------------------------------------------------------------}
  269. Procedure RA;  begin               (* Amps * Ohms *)
  270.  
  271.   For I:=1 to 6 do begin
  272.     Gotoxy(15,11+I);  Write('                                           ');
  273.   end;
  274.  
  275.   Gotoxy(18,20); Write('Enter Amps  ');  Read(A);
  276.   Gotoxy(38,20); Write('Enter Ohms  ');  Read(OH);
  277.  
  278.                                  V:=A*OH;  W:=V*A;
  279.   Writestuff;
  280.   Presskey;
  281. end;
  282.   {----------------------------------------------------------------}
  283. Procedure WV;  Label 99;  begin               (* Watts & Volts *)
  284.  
  285.   For I:=1 to 6 do begin
  286.     Gotoxy(15,11+I);  Write('                                           ');
  287.   end;
  288.  
  289.   Gotoxy(18,20); Write('Enter Watts ');  Read(W);
  290.   Gotoxy(38,20); Write('Enter Volts ');  Read(V);
  291. If ((V=0) or (W=0)) then Goto 99;
  292.                                 A:=W/V;  OH:=V/A;
  293.   Writestuff;
  294. 99:   Presskey;
  295. end;
  296. {-------------------------------------------------------------------}
  297. Procedure WA;  Label 99;   begin               (* Watts & Amps *)
  298.  
  299.   For I:=1 to 6 do begin
  300.     Gotoxy(15,11+I);  Write('                                           ');
  301.   end;
  302.  
  303.   Gotoxy(18,20); Write('Enter Watts ');  Read(W);
  304.   Gotoxy(38,20); Write('Enter Amps  ');  Read(A);
  305.      If A=0 then Goto 99;
  306.                                 V:=W/A;  OH:=V/A;
  307.   Writestuff;
  308. 99:    Presskey;
  309. end;
  310. {-------------------------------------------------------------------}
  311. Procedure WR;  Label 99;   begin               (* Watts & Ohms *)
  312.  
  313.   For I:=1 to 6 do begin
  314.     Gotoxy(15,11+I);  Write('                                           ');
  315.   end;
  316.  
  317.   Gotoxy(18,20); Write('Enter Watts ');  Read(W);
  318.   Gotoxy(38,20); Write('Enter Ohms  ');  Read(OH);
  319.     If OH=0 then Goto 99;
  320.                           A:=Sqrt(W/OH);  V:=OH*A;
  321.   Writestuff;
  322. 99:  Presskey;
  323. end;
  324. {-------------------------------------------------------------------}
  325. Procedure Page3;
  326. Begin
  327.         Textmode(2);  If Ch<>'A' then ClrScr;
  328.  
  329.  
  330.   Gotoxy(1,9);
  331. Writeln('              Volts = Amps x Ohms    Watts = Amps x Volts  ');
  332.   Gotoxy(1,12);
  333. Writeln('              Press the Number for the 2 things you know.  ');
  334.   Writeln;
  335. Writeln('                  1  Volts & Ohms.    4  Watts & Volts.    ');
  336. Writeln('                  2  Volts & Amps.    5  Watts & Amps.     ');
  337. Writeln('                  3  Ohms  & Amps.    6  Watts & Ohms.     ');
  338.  
  339. Xlow:=13;  Yhi :=11; Hlen:=45; Vlen:=6;  Boxes;
  340.  
  341.       Gotoxy(15,16);          (* Position cursor. *)
  342.   Repeat
  343.     Read(Kbd,Ch);
  344.     Ch:=UpCase(Ch);
  345.   until (Ch in ['1','2','3','4','5','6']);
  346.  
  347.   If (Ch='1') then VR;
  348.   If (Ch='2') then VA;
  349.   If (Ch='3') then RA;
  350.   If (Ch='4') then WV;
  351.   If (Ch='5') then WA;
  352.   If (Ch='6') then WR;
  353. End;
  354. {===================================================================}
  355.                 Procedure Page4; Forward;
  356. Procedure Page6;        (*******  HYPERBOLA & FRACTIONS ********)
  357. Begin  Clrscr;
  358.   Gotoxy(1,2);
  359.  
  360. Writeln('                Fractions, Rates, Reciprocals, and Hyperbola.               ');
  361. Writeln('                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~               ');
  362. Writeln('      We discuss these topics together, because they have related features. ');
  363. Writeln('      You won`t find this in books.  Their authors don`t bother to show you ');
  364. Writeln('                these relationships.  Their definitions are:                  ');
  365. Writeln('                ___________________________________________           ') ;
  366.   Writeln;
  367. Writeln('          Fraction :  An indicated division of the number 1.                ');
  368.   Writeln;
  369. Writeln('            Rate   :  Change in Y per unit change in X (right triangle).    ');
  370.   Writeln;
  371. Writeln('         Reciprocal:  Make a fraction of a number.                          ');
  372. Writeln('         -------------------------------------------------------------- ');
  373.   Key;Gotoxy(1,15);
  374. Writeln('      Examples:  1/2 : Fraction.    Indicates 1 is divided into 2 parts. ');
  375.   Writeln;
  376. Writeln('                 2/1 : Rate.        Y goes up 2 for each X unit.            ');
  377.   Writeln;
  378. Writeln('                 1/2 : Reciprocal.  The reciprocal of 2 is 1/2.             ');
  379. Writeln('                 ----------------------------------------------       ');
  380.   Key;Gotoxy(1,21);
  381. Writeln('           The reciprocal of a reciprocal gives the number back again.  ');
  382. Writeln('           Example:  The reciprocal of 1/2 is 2.   Check it yourself!   ');
  383.   Key;
  384.  
  385.   Clrscr;Gotoxy(1,1);
  386. Writeln('       We have just seen ways of relating 2 numbers, a top and a  ');
  387. Writeln('       bottom number.  Often, however, we relate a set of numbers ');
  388. Writeln('       to another set.                                            ');
  389.   Writeln;
  390. Writeln('       For example, a linear equation relates a set of X numbers  ');
  391. Writeln('       to a Y set.  Two forms of Ohm`s law are linear equations.  ');
  392.   Key;Gotoxy(1,8);
  393. Writeln('       Just for fun, suppose we look at the set of all whole num- ');
  394. Writeln('       bers and their fractions.   Pictures are better than words, ');
  395. Writeln('                    so we make a picture this way:                 ');
  396.    Key;Gotoxy(1,12);
  397. Writeln('     1   #  1  ###################################################### ');
  398. Writeln('     2   # 1/2 ########################                          ');
  399. Writeln('     3   # 1/3 ##############                                    ');
  400. Writeln('     4   # 1/4 #########                                         ');
  401. Writeln('     5   # 1/5 ######                                            ');
  402. Writeln('     6   # 1/6 ####                                              ');
  403.   Key;
  404. Gotoxy(1,25);For I:=1 to 10 do Writeln;
  405.   Gotoxy(1,9);
  406. Writeln('       Numbers are shown on the left, and the lengths of the cross-   ');
  407. Writeln('       hatched bars represent values of the fractions.                ');
  408.   Writeln;
  409. Writeln('       Number 1 is 60 hatches long, 1/2 is 30, and so on.   Only a   ');
  410. Writeln('       few values can be shown, because they quickly become smaller. ');
  411. Writeln('                    Now comes something important.                                ');
  412.   Key;Gotoxy(1,16);
  413. Writeln('       Consider the bars as representing all possible values between ');
  414. Writeln('       the whole numbers too, i.e. like 1.5.   Then we would have a  ');
  415. Writeln('       smooth, graceful curve.                                       ');
  416.   Writeln;
  417. Writeln('       Starting at 1, it drops rapidly. Its slope decreases, however,');
  418. Writeln('       so that the farther from 1 we go, the more it flattens out.   ');
  419.   Key;Gotoxy(1,20);
  420. Writeln('       We formed our curve starting with numbers.  But what happens  ');
  421. Writeln('       when we use fractions too?  The range of fractions is 0 - 1.  ');
  422. Writeln('                 We do that now, and see what happens.               ');
  423. Writeln('                 -------------------------------------               ');
  424.  
  425.   Key;Clrscr;Gotoxy(1,5);
  426. Writeln('       For this part of the curve, we start with 1/2.  Next is    ');
  427. Writeln('       1/3, 1/4, and so on.  All are within the interval 0 - 1.   ');
  428.   Writeln;
  429. Writeln('       The length of each bar is the reciprocal of the number, so  ');
  430.   Writeln;
  431. Writeln('                1/(1/2) = 2   1/(1/3) = 3   and so on.             ');
  432.   Key;Gotoxy(1,12);
  433. Writeln('       Our bar-lengths are now the whole numbers, and the scale is ');
  434. Writeln('       their fractions - the opposite of our curve starting at 1!  ');
  435.   Key;Gotoxy(1,15);
  436. Writeln('       Again, assume we include numbers, like .9, between the frac- ');
  437. Writeln('       tions, so we have a smooth curve here too.                   ');
  438.   Writeln;
  439. Writeln('       The complete curve is boomerang-shaped.  The part in the ra- ');
  440. Writeln('       ange 0 - 1 is the `mirror image` of the other.  And we have  ');
  441. Writeln('               all positive numbers in the interval 0 - 1!          ');
  442.   Key;Gotoxy(1,22);
  443. Writeln('                     Now, what does all this mean?                    ');
  444. Writeln('                     -----------------------------                    ');
  445.  
  446. Key;Clrscr;
  447. Gotoxy(1,5);
  448. Writeln('                         Mathematics Viewpoint.                    ');
  449. Writeln('                         ~~~~~~~~~~~~~~~~~~~~~~                    ');
  450. Writeln('            The boomerang shaped curve we have just seen is fund-  ');
  451. Writeln('            amental in mathematics.  It`s called a `rectangular    ');
  452. Writeln('            hyperbola.`                                            ');
  453.    Writeln;
  454. Writeln('            For more information about its mathematics, look it    ');
  455. Writeln('            up in a math dictionary.  It`s 1 of 3 curves called    ');
  456. Writeln('            `conic sections.`                                      ');
  457.   Writeln;
  458. Writeln('            You will encounter the other 2 conic section curves,   ');
  459. Writeln('            the parabola and ellipse, in later programs.  All      ');
  460. Writeln('            arise in various ways and have many practical uses.    ');
  461.   Writeln;
  462. Writeln('            We introduced it as picturing `all positive numbers`   ');
  463. Writeln('            partly because it`s interesting, and partly because    ');
  464. Writeln('                Ohm`s law is hyperbolic.  We discuss it now.      ');
  465. Writeln('                --------------------------------------------      ');
  466.  
  467.   Key;Clrscr; Gotoxy(1,2);
  468. Writeln('                        Flow Characteristics.                      ');
  469. Writeln('                        ~~~~~~~~~~~~~~~~~~~~~                      ');
  470. Writeln('        Consider a circuit where volts are fixed, which is usual.  ');
  471. Writeln('        If we increase resistance, flow decreases, and the reverse ');
  472. Writeln('        is true.  In mathematical language, we call these `inverse ');
  473. Writeln('        relationships.`  As one quantity goes up the other goes    ');
  474. Writeln('        down, like a seesaw.                                       ');
  475.   Writeln;
  476. Writeln('        The facts are so obvious that they are easily understood.  ');
  477. Writeln('        What will take getting used to, however, is how much chan- ');
  478. Writeln('        ge can be expected in various situations.  This is where   ');
  479. Writeln('        the shape of curve is important.                           ');
  480.   Writeln;
  481. Writeln('        Using our mathematical model for discussion, we saw that   ');
  482. Writeln('        in the range 0 - 1, huge Y value changes occur with small  ');
  483. Writeln('        X value changes.  But, for instance, around an X value of  ');
  484. Writeln('        5, little change in Y occurs.                              ');
  485.   Writeln;
  486. Writeln('        In terms of electron flow, where flow is already small,    ');
  487. Writeln('        small resistance changes have little effect.  The same     ');
  488. Writeln('           change when flow is great will have much effect.        ');
  489. Writeln('           ------------------------------------------------        ');
  490.  
  491. Node;
  492.   Page4;
  493. end;   (* Procedure Page6. *)
  494. {====================================================================}
  495.                     Procedure Page5; Forward;
  496. Procedure Page4;
  497.   Begin  Clrscr;
  498.   Gotoxy(1,1);
  499. Writeln('                    The Mathematics of Ohm`s Law                    ');
  500. Writeln('                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~                    ');
  501. Writeln('        Basic books give Ohm`s law as V = AR  (or E = IR). They     ');
  502. Writeln('        do not describe, however, the simple mathematics behind     ');
  503. Writeln('        it.  We do that here, and relate it to other things too.    ');
  504.   Writeln;
  505. Writeln('        Electricity is the flow of electrons (or holes, which is   ');
  506. Writeln('        their lack).  By regarding it as `flow` we can relate it   ');
  507. Writeln('        to flows of anything, including the flow of water in the   ');
  508. Writeln('        kitchen sink.   Math useful for one kind of flow is use-   ');
  509. Writeln('                     ful for most all other kinds!                 ');
  510.   Writeln;
  511. Writeln('               We relate math and electronics this way:       ');
  512.   Key;Gotoxy(1,25);For I:=1 to 6 do Writeln;
  513.           Xlow:=8; Yhi:=8; Hlen:=54; Vlen:=5;  Boxes;
  514.  
  515. Gotoxy(10,10);Write(' A constant flow is described by a Linear Equation.');
  516. Gotoxy(10,12);Write('       Math:  Y = mX.     Electronics: V = AR.     ');
  517. Gotoxy(8,16); Writeln('    For details about them, see Math21 on this disk.');
  518.   Key;Gotoxy(1,15);
  519.  
  520. Writeln('       By International Agreement: 1 Amp of Current flows with  ');
  521. Writeln('                                   1 Volt of pressure applied to');
  522. Writeln('           (Measurement Units)     1 Ohm of Resistance.         ');
  523.   Key; Gotoxy(1,19);
  524. Writeln('       All 3 may be different in different circuits.  It`s easy ');
  525. Writeln('       to study them, however.  Just fix one of the 3, and let  ');
  526. Writeln('       one of the others vary.  With 2 of them known, the third ');
  527. Writeln('       is computed from the 2 knowns.  The equation shows the   ');
  528. Writeln('       `whole picture` with one of them fixed.  For example:    ');
  529.   Key;Gotoxy(1,25); For I:=1 to 7 do Writeln;
  530.   Gotoxy(1,18);
  531. Writeln('                  Fix Amps at 2    Fix Ohms at 100  ');
  532. Writeln('                  ~~~~~~~~~~~~~    ~~~~~~~~~~~~~~~  ');
  533. Writeln('                     V = 2xR          V = 100xA     ');
  534.   Key; Gotoxy(1,22);
  535. Writeln('       See that they really are linear equations?  Don`t expect   ');
  536. Writeln('       get it all the first time.  Now on to computer plotting.   ');
  537. Writeln('       --------------------------------------------------------   ');
  538.   Key; Clrscr; Gotoxy(1,4);
  539.  
  540. Writeln('                    Scaling for Computer Plotting                 ');
  541. Writeln('                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                 ');
  542. Writeln('       Volts, Amps, and Ohms cover a tremendous range of values.');
  543. Writeln('       Computer screens have few usable characters and sizes. It ');
  544. Writeln('       thus is not possible to show on the screen the scales for ');
  545. Writeln('       electronic units as they are written in books.           ');
  546.   Writeln;
  547. Writeln('       Because of this, the `plotting graph` given next has axes ');
  548. Writeln('       of zero through 6, like those in the math programs.      ');
  549.   Key; Gotoxy(1,14);
  550. Writeln('       You must scale the axes yourself, but it`s easy to do.    ');
  551. Writeln('       Just mentally move the decimal point where you want the   ');
  552. Writeln('       scale ranges.   This will help you learn scaling too.     ');
  553.   Writeln;
  554. Writeln('       We saw that by fixing either Amps or Ohms, linear equa-  ');
  555. Writeln('       tions result.  But what happens when we fix Volts?       ');
  556. Writeln('          ---------------------------------------------         ');
  557.   Key;Clrscr;Gotoxy(1,3);
  558. Writeln('            Ohm`s Law with Volts Fixed - Rectangular Hyperbola.       ');
  559. Writeln('            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       ');
  560. Writeln('       When volts are fixed in Ohm`s law, the curve produced is called ');
  561. Writeln('       a `Rectangular Hyperbola.`  Another name is `boomerang curves.` ');
  562. Writeln('          From the math and electronics viewpoints, here they are:     ');
  563.   Writeln;
  564. Writeln('                      Math Hyperbola        Volts Fixed                ');
  565. Writeln('                      ~~~~~~~~~~~~~~        ~~~~~~~~~~~                ');
  566. Writeln('                         Y = k/X              A = v/R.                 ');
  567.   Writeln;
  568. Writeln('                Obviously the two expressions are identical.          ');
  569.   Key;Gotoxy(1,15);
  570. Writeln('        And it`s the same curve we discussed with fractions!  Here,  ');
  571. Writeln('        however, you can begin to relate them to electronics.  The   ');
  572. Writeln('        computer will plot one for you.  The curve is for k = 1. Of  ');
  573. Writeln('        course different curves will result with different k values, ');
  574. Writeln('                      but all are boomerang-shaped.                ');
  575. Writeln('                      -----------------------------                ');
  576.  
  577. Gotoxy(23,22);Write('Want the hyperbola too? (Y/N) ');
  578.   Repeat
  579.     Read(Kbd,Ch);
  580.     Ch:=Upcase(ch);
  581.   until (Ch in ['Y','N']);
  582.     Boom:=Ch;
  583. Gotoxy(20,22); Write('Now, on to linear equation plotting.   ');
  584.   Node;
  585.     Page5;
  586. end;  (* Procedure Page4. *)
  587. {===================================================================}
  588.             (*********  DRAWS HYPERBOLA  *********)
  589. Procedure Hyperbola;
  590. Var        Xr,Yr,Xc,Yc  : Real;
  591.                  Np,X,Y :Integer;
  592.           Xrange,Yrange :Real;
  593.   {----------------------------------------------------------------}
  594. Begin
  595.       Np:=120;    Xc:=Xhlow;             Yc:=Yhlow;
  596.              Xrange:=Xhhi-Xhlow-2;  Yrange:=Yhlow-Yhhi;
  597.   Xr:=0.0;
  598.  
  599. For I:=1 to Np do begin
  600.   Xr:=Xr+0.05;                         (* Compute Actual Values. *)
  601.   Yr:=1/Xr;
  602.  
  603.   Xc:=(Xrange/6)*(Xr)+Xhlow;         (* Scale transform to plot. *)
  604.       Xc:=Round(Xc);   X:=Trunc(Xc);
  605.   Yc:=Yhlow-(Yrange/6)*(Yr-0.0);
  606.       Yc:=Round(Yc);   Y:=Trunc(Yc);
  607.  
  608.   Plot(X,Y,1);
  609. end;
  610.  
  611. end;
  612. {===================================================================}
  613. Procedure Axes;
  614. Begin
  615.         Xlow:=10;        Yhi:= 4;           (* Axis specifications. *)
  616.         Hlen:=24;       Vlen:=12;
  617.                        Yzero:=Yhi+Vlen;
  618.   {-----------------------------------------------------------------}
  619.  
  620. Xhlow:=8*Xlow-2;          Yhhi:=8*Yhi -4;      (*  Compute Hi-res   *)
  621.  Xhhi:=8*Hlen+Xhlow-2;   Yhlow:=8*Vlen+Yhhi;   (* scale end points. *)
  622.  
  623.   {---------------------------------------------------------------}
  624.                   Yinc:=Yhi+1;
  625.                   Vindx:=Round(Vlen/2);
  626. Gotoxy(26,1); Write(' Computer Draws Your Lines. ');
  627. Gotoxy(26,2); Write(' ~~~~~~~~~~~~~~~~~~~~~~~~~~ ');
  628. Gotoxy(Xlow,Yhi);  Write(#218);
  629. For I:=1 to Vindx do begin                 (* Write Yaxis. *)
  630.   Gotoxy(Xlow, Yinc);
  631.     Write(#195);
  632.   Gotoxy(Xlow,Yinc+1);
  633.     Write(#197);
  634.       Yinc:=Yinc+2;
  635. end;
  636.  
  637. Ysc:=0;   Ty:=Yzero;                       (* Write Y scale numbers.*)
  638.   For I:=0 to 6 do begin
  639.     Gotoxy(Xlow-2,Ty); Write(Ysc);
  640.       Ysc:=Ysc+1;
  641.        Ty:=Ty-2;
  642.   end;
  643.  
  644. Gotoxy(Xlow,Yzero);  Write(#192);          (*  Write corner. *)
  645.   {---------------------------------------------------------------}
  646.  
  647.   Xwide:=Round(Hlen/2);
  648.    Xinc:=Xlow;
  649.  
  650. For I:=1 to Xwide do begin                 (* Write X axis.*)
  651.   Gotoxy(Xinc+1, Yzero);
  652.     Write(#196,#194);
  653.     Xinc:=Xinc+2;
  654. end;
  655.  
  656. Gotoxy(Xlow,Yhi+Vlen+1);                   (* Write X Scale numbers.*)
  657.   For I:= 0 to 6 do Write(I,'   ');
  658.  
  659.   {---------------------------------------------------------------}
  660.  
  661.     Draw(Xhlow,Yhhi,Xhhi,Yhhi ,1);         (* Put box around axes.*)
  662.     Draw(Xhhi ,Yhhi,Xhhi,Yhlow,1);
  663.  
  664.     Draw(Xhlow,Yhhi+32,Xhhi,Yhhi+32,1);    (* Draw `graph paper` lines.*)
  665.     Draw(Xhlow,Yhhi+64,Xhhi,Yhhi+64,1);
  666.     Draw(Xhlow+ 62,Yhlow,Xhlow+ 62,Yhhi,1);
  667.     Draw(Xhlow+126,Yhlow,Xhlow+126,Yhhi,1);
  668.  
  669. Gotoxy(5,4); Write('Y');  Gotoxy(37,17); Write('X');
  670. Gotoxy(1,7); Write('Volts'); Gotoxy(4,18);Write('Ohms or Amps');
  671.   Gotoxy(1,21);
  672.  
  673. Writeln('       Math     Electronics     Example: Fix Amps at 0.02, Ohms scale x100.  ');
  674. Writeln('       ~~~~     ~~~~~~~~~~~     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ');
  675. Writeln('      Y = mX      V = aR                   Input a slope of 2.        ');
  676. Writeln('                  V = rA           NO change needed in the Volts scale.      ');
  677.  
  678.   Xlow:=4; Yhi:=20; Hlen:=24; Vlen:=4;  Boxes;
  679. end;     (* Procedure Axes. *)
  680.  
  681. {====================================================================}
  682. Procedure Page5;   Label 99;
  683.  
  684. Begin             (********** EQUATIONS CONTROL ************)
  685.  
  686. Hires; Axes;  Neq:=1;
  687.   If Boom='Y' then Hyperbola; Boom:='N';
  688.   GraphWindow(0,24,300,130);
  689.  
  690. Repeat
  691.   Gotoxy(40, 5+Neq);
  692.  
  693.   Ycept:=0.0;    Y1off:=Round(16*Ycept+24);
  694.  
  695. Gotoxy(40, 6+Neq);    Neq:=Neq+2;
  696. Write(' Input Slope (0 to 100) ');
  697.   Read(Slope);   Y2off:=Round(96*Slope);
  698.  
  699. Gotoxy(40,Neq+3); Write('    y = ',Slope:2:1,'x            ');
  700. Gotoxy(40,Neq+4); Write('                                  ');
  701. Draw(Xhlow,Yhlow-Y1off,Xhlow+190,Yhlow-Y1off-Y2off,1);
  702.  
  703.   If Neq>9  then Goto 99;
  704. Gotoxy(40,17);
  705.   If Neq<=7 then  Write('  Another equation (Y/N) ? ');
  706.   If Neq>7  then  Write('   1 more equation (Y/N) ? ');
  707.     Repeat
  708.         Read(Kbd,Ch);
  709.         Ch:=Upcase(ch);
  710.       until (Ch In ['Y','N']);
  711.   Gotoxy(40,17);Write('                              ');
  712. until Ch='N';
  713.   99:
  714. Gotoxy(4,20); For I:=1 to 7 do
  715. Write('                                                                 ');
  716.   Key;
  717.  
  718.  Textmode(2);
  719.  Clrscr;
  720.   {---------------------------------------------------------------}
  721. Gotoxy(20,9); Write('   End Of Program Ohm1 of the Series:');
  722. Gotoxy(20,10); Write('Foundations of Science and Mathematics.');
  723.     Xlow:=17; Yhi:=7; Hlen:=42; Vlen:=4;  Boxes;
  724.  
  725. Gotoxy(24,15); Write('The Program Ohm2 covers Series ');
  726. Gotoxy(24,16); Write('    and Parallel Circuits.   ');
  727. Gotoxy(24,17); Write('    ----------------------   ');
  728. Gotoxy(23,24);
  729. Write('Press `M` for Menu, `Q` to Quit.');
  730.   Repeat
  731.     Read(Kbd,Ch);
  732.     Ch:=Upcase(Ch);
  733.   until (Ch in ['M','Q']);
  734. If Ch='M' then MainControl;
  735.  
  736. end;  (* Procedure Page5. *)
  737. {===================================================================}
  738. Procedure MainControl;
  739.  
  740. Begin  Clrscr;  Boom:='N';      (* *** MAIN CONTROL *** *)
  741.     Assign(Ccontrol,'Control.com');
  742.  
  743.   Gotoxy(1,3);
  744. Writeln('                      Electronics #1  Basic Ohm`s Law               ');
  745. Writeln('                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~               ');
  746.   Gotoxy(1,7);
  747. Writeln('              First electronics program.  Covers basic facts   ');
  748. Writeln('              of electron flow.   A section explains why the   ');
  749. Writeln('                      fundamental equations `work.`           ');
  750.   Writeln;
  751. Writeln('            For further details about the mathematics on which    ');
  752. Writeln('            science is based, see the math series on this disk.   ');
  753.   Xlow:=10; Yhi:=5; Hlen:=55; Vlen:=8;  Boxes;
  754.   Gotoxy(1,17);
  755.  
  756. Writeln('                1 Basic explanation.     4 The Math of Ohm`s law. ');
  757. Writeln('                2 Ohm`s law computing.   5 Computer draws lines.  ');
  758. Writeln('                3 Hyperbola & fractions.                          ');
  759. Writeln('                                C Control program.                ');
  760. Writeln('                    _________________________________________     ');
  761.  
  762. Gotoxy(70,25);Write('Oct 1985');
  763. Gotoxy( 1,25);Write('Ohm1');
  764. Gotoxy(20,25);Write('     Press key for topic wanted.');
  765.   Gotoxy(3,17);  Write('I want no.');
  766.  
  767.   Repeat
  768.     Read(Kbd,Ch);
  769.     Ch:=Upcase(ch);
  770.   until (Ch in ['1','2','3','4','5','C']);
  771.  
  772.   If Ch='1' then Page2;
  773.   If Ch='2' then Page3;
  774.   If Ch='3' then Page6;
  775.   If Ch='4' then Page4;
  776.   If Ch='5' then Page5;
  777.   If Ch='C' then Execute(Ccontrol);
  778.  
  779. end;  (* Procedure MainControl. *)
  780. {==================================================================}
  781. Begin                        (*********  MAIN PROGRAM **********)
  782.  
  783. MainControl;
  784.  
  785. End.   (* Everything. *)
  786. {===================================================================}